Ask "Enter Angle or Coordinates (see note above)" with it
hide card field 10
put it into card field 4
end mouseUp
-- part 4 (button)
-- low flags: 00
-- high flags: 2000
-- rect: left=263 top=102 right=129 bottom=313
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: °B
----- HyperTalk script -----
on mouseUp
get card field 5
show card field 10
Ask "Enter Angle or Coordinates (see note above)" with it
hide card field 10
put it into card field 5
end mouseUp
-- part 5 (button)
-- low flags: 00
-- high flags: 2000
-- rect: left=374 top=49 right=77 bottom=410
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: °C
----- HyperTalk script -----
on mouseUp
get card field 6
show card field 10
Ask "Enter Angle or Coordinates (see note above)" with it
hide card field 10
put it into card field 6
end mouseUp
-- part 7 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=346 top=84 right=96 bottom=396
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name:
-- part 8 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=426 top=84 right=97 bottom=498
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name:
-- part 9 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=354 top=125 right=137 bottom=406
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name:
-- part 10 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=431 top=104 right=117 bottom=512
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name:
-- part 11 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=312 top=104 right=116 bottom=413
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name:
-- part 12 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=405 top=61 right=75 bottom=512
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name:
-- part 13 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=150 top=310 right=334 bottom=339
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Calculate
----- HyperTalk script -----
on mouseUp
global ii,sa,sb,sc,aa,ab,ac,cc,ms
put 0 into cc
put empty into ms
set cursor to 4
repeat with x=1 to 6
if offset(",",card field x)>0 then put 1 into cc
if card field x=0 then put "Error... Cannot accept zero entries" into ms
end repeat
if ms is not empty then
mss
exit mouseup
end if
if cc=1 then coordinate
if cc=6 then exit mouseup
if cc>1 then
if cc=2 then put "Error ...entries of Sides are not allowed when you choose Coordinates" into ms
if cc=3 then put "Error ... Not enough data" into ms
if cc=4 then put "Error ... Some Coordinates have wrong Format" into ms
if cc=5 then put "Error... These values do not give a real solution" into ms
mss
exit mouseup
end if
put card field 1 into sa
put card field 2 into sb
put card field 3 into sc
put card field 4 into aa
put card field 5 into ab
put card field 6 into ac
if sa is empty then put 0 into sa
if sb is empty then put 0 into sb
if sc is empty then put 0 into sc
if aa is empty then put 0 into aa
if ab is empty then put 0 into ab
if ac is empty then put 0 into ac
if offset("-",sa&sb&sc&aa&ab&ac)<>0 then put "Error ... cannot accept negative entries" into ms
if aa+ab+ac>180 then put "Error .. Angles are more than 180°" into ms
if ms is not empty then
mss
exit mouseup
end if
put 0 into ii
if aa>0 and ab>0 and ac=0 then put 180-aa-ab into ac
if ab>0 and ac>0 and aa=0 then put 180-ab-ac into aa
if aa>0 and ac>0 and ab=0 then put 180-aa-ac into ab
if abs(aa)>0 and abs(ab)>0 and abs(ac)>0 then
if abs(aa)+abs(ab)+abs(ac)<>180 or offset("-",aa&ab&ac)<>0 then put "Error... Angles do not add up to 180°" into ms
put 1 into ii
if sa=0 and sb=0 and sc>0 then put 2 into ii
if sa=0 and sc=0 and sb>0 then put 2 into ii
if sb=0 and sc=0 and sa>0 then put 2 into ii
if sa=0 and sb=0 and sc=0 then put 2 into ii
end if
if ms is empty and ii=1 then put "Too Many Data Elements!" into ms
if ms is not empty then
mss
exit mouseup
end if
if ii=2 and ms is empty then
calculate
exit mouseup
end if
put 0 into count
if sa=0 then add 1 to count
if sb=0 then add 1 to count
if sc=0 then add 1 to count
if aa=0 then add 1 to count
if ab=0 then add 1 to count
if ac=0 then add 1 to count
if (ab>0 and ac>0) or (ab>0 and aa>0) or (ac>0 and aa>0) then put "This is a straight line !" into ms
if ms is empty and count >3 then put "Error... Not enough Data !" into ms
if ms is empty and count <3 then put "Error... Too Many Data Elements!" into ms
if ms is not empty then
mss
exit mouseup
end if
calculate
set cursor to 1
end mouseUp
on coordinate -- **** --
global cc,ms
put empty into ms
repeat with x=1 to 3
if card field x is not empty then put 2 into cc
end repeat
if cc=2 then exit coordinate
put 0 into j
repeat with x=4 to 6
if card field x is empty then add 1 to j
end repeat
if j>1 then
put 3 into cc
exit coordinate
end if
put item 1 of card field 4 into xh
put item 2 of card field 4 into xv
put item 1 of card field 5 into yh
put item 2 of card field 5 into yv
put item 1 of card field 6 into zh
put item 2 of card field 6 into zv
if (card field 4 is not empty and offset(",",card field 4)=0) or (card field 5 is not empty and offset(",",card field 5)=0) or (card field 6 is not empty and offset(",",card field 6)=0) then
put 4 into cc
exit coordinate
end if
put empty into card field 12
put empty into card field 7
put empty into card field 8
if card field 4 is empty or card field 5 is empty or card field 6 is empty then
put 0 into h
put 0 into v
if card field 4 is not empty and card field 5 is not empty and card field 6 is empty then
if xh=yh then put 1 into v
if xv=yv then put 1 into h
if xv>=yv then
put xv into cv
put xh into ch
put yv into av
put yh into ah
else
put xv into av
put xh into ah
put yv into cv
put yh into ch
end if
end if
if card field 4 is not empty and card field 6 is not empty and card field 5 is empty then
if xh=zh then put 1 into v
if xv=zv then put 1 into h
if xv>=zv then
put xv into cv
put xh into ch
put zv into av
put zh into ah
else
put xv into av
put xh into ah
put zv into cv
put zh into ch
end if
end if
if card field 6 is not empty and card field 5 is not empty and card field 4 is empty then
if zh=yh then put 1 into v
if zv=yv then put 1 into h
if zv>=yv then
put zv into cv
put zh into ch
put yv into av
put yh into ah
else
put zv into av
put zh into ah
put yv into cv
put yh into ch
end if
end if
put sqrt(((ch-ah)^2)+((cv-av)^2)) into len
if h =1 then
if ch>ah then
put ch into tah
put ah into ch
put tah into ah
end if
put 0 into tch
put 205 into tah
put 1 into tav
put 1 into tcv
put 0 into ang
end if
if v =1 then
if cv>av then
put cv into tah
put av into cv
put tah into av
end if
put 2 into tah
put 2 into tch
put 0 into tcv
put 205 into tav
put 90 into ang
end if
if h=0 and v=0 then
put min(ch,ah) into minh
put min(cv,av) into minv
put abs(ch-ah) into maxh
put abs(cv-av) into maxv
put max(maxh,maxv) into max
put 190/max into ratio
put round(ratio*(ch-minh)) into tch
put round(ratio*(cv-minv)) into tcv
put round(ratio*(ah-minh)) into tah
put round(ratio*(av-minv)) into tav
put (180/pi)*atan((cv-av)/(ch-ah)) into ang
if ang<0 then add 180 to ang
end if
if offset("N",ang&len) <>0 then
put 5 into cc
exit coordinate
end if
set numberformat to "0.0000"
put "Distance between the two points =" into line 2 of card field 12
put len into line 5 of card field 7
put "Angle with the Horizontal Axis =" into line 4 of card field 12
put ang&"°" into line 10 of card field 7
Choose select tool
Drag from 17,50 to 253,302
domenu clear picture
if len=0 then
choose text tool
click at 130,170
type "•"&&" ("&ch&","&cv&")"
put empty into line 5 of card field 7
put 6 into cc
choose browse tool
exit coordinate
end if
choose line tool
set linesize to 1
drag from 25,285 to 250,285
drag from 35,295 to 35,55
set linesize to 2
put 35+tch into locc
put 35+tah into loca
drag from locc,285-tcv to loca,285-tav
choose text tool
set textfont to geneva
set textsize to 9
put round(5.5*(1+(length(ch)+length(cv)))) into textc
put round(5.5*(1+(length(ah)+length(av)))) into texta
if locc+textc >250 then put 240-textc into locc
if loca+texta >240 then put 240-texta into loca
click at locc+8,281-tcv
type ch&","&cv
click at loca+8,281-tav
type ah&","&av
else
put max(xh,yh,zh) into maxh
put min(xh,yh,zh) into minh
put min(xv,yv,zv) into minv
if xv>=yv and xv>=zv then
put xv into cv
put xh into ch
if yh>=zh then
put yh into ah
put yv into av
put zh into bh
put zv into bv
else
put zh into ah
put zv into av
put yh into bh
put yv into bv
end if
end if
if yv>=xv and yv>=zv then
put yv into cv
put yh into ch
if xh>=zh then
put xh into ah
put xv into av
put zh into bh
put zv into bv
else
put zh into ah
put zv into av
put xh into bh
put xv into bv
end if
end if
if zv>=xv and zv>=yv then
put zv into cv
put zh into ch
if yh>=xh then
put yh into ah
put yv into av
put xh into bh
put xv into bv
else
put xh into ah
put xv into av
put yh into bh
put yv into bv
end if
end if
put cv into maxv
if maxv-minv>=maxh-minh then put maxv-minv into max
if maxv-minv<maxh-minh then put maxh-minh into max
put sqrt(((ah-bh)^2)+((av-bv)^2)) into sc
put sqrt(((ch-ah)^2)+((cv-av)^2)) into sb
put sqrt(((ch-bh)^2)+((cv-bv)^2)) into sa
put ((sb^2)+(sc^2)-(sa^2))/(2*sb*sc) into cosa
put sqrt(1-cosa^2) into sina
put (180/pi)*atan(sina/cosa) into aa
if aa<0 then put 180+aa into aa
put ((sa^2)+(sc^2)-(sb^2))/(2*sa*sc) into cosb
put sqrt(1-cosb^2) into sinb
put (180/pi)*atan(sinb/cosb) into ab
if ab<0 then put 180+ab into ab
put 180-aa-ab into ac
put (sa+sb+sc)/2 into s
put sqrt(s*(s-sa)*(s-sb)*(s-sc)) into area
set numberformat to "0.0000"
put "angle A'=" into line 2 of card field 12
put 1*aa&"°" into line 2 of card field 7
put "angle B'=" into line 3 of card field 12
put 1*ab&"°" into line 3 of card field 7
put "angle C'=" into line 4 of card field 12
put 1*ac&"°" into line 4 of card field 7
put "side A'B'=" into line 6 of card field 12
put 1*sc into line 6 of card field 7
put "side B'C'=" into line 7 of card field 12
put 1*sa into line 7 of card field 7
put "side C'A'=" into line 8 of card field 12
put 1*sb into line 8 of card field 7
put "Area =" into line 10 of card field 12
put area into line 10 of card field 7
if offset("N",sa&sb&sc&aa&ab&ac)<>0 or min(sa,sb,sc,aa,ab,ac)<0 then
put 5 into cc
exit coordinate
end if
put 210/max into ratio
Choose select tool
Drag from 17,50 to 253,302
domenu clear picture
choose line tool
set linesize to 2
drag from 35+round(ratio*(ch-minh)),285-round(ratio*(cv-minv)) to 35+round(ratio*(bh-minh)),285-round(ratio*(bv-minv))
drag from 35+round(ratio*(bh-minh)),285-round(ratio*(bv-minv)) to 35+round(ratio*(ah-minh)),285-round(ratio*(av-minv))
drag from 35+round(ratio*(ah-minh)),285-round(ratio*(av-minv)) to 35+round(ratio*(ch-minh)),285-round(ratio*(cv-minv))
choose text tool
set textfont to geneva
set textsize to 9
put 35+round(ratio*(ch-minh)) into locc
put 35+round(ratio*(bh-minh))into locb
put 45+round(ratio*(ah-minh)) into loca
put round(6.5*(3+(length(ch)+length(cv)))) into textc
put round(6.5*(3+(length(bh)+length(bv)))) into textb
put round(6.5*(3+(length(ah)+length(av)))) into texta
if locc+textc >250 then put 240-textc into locc
if locb+textb >250 then put 240-textb into locb
if loca+texta >240 then put 240-texta into loca
click at locc,275-round(ratio*(cv-minv))
type "C' ("&ch&","&cv&")"
click at locb,298-round(ratio*(bv-minv))
type "B' ("&bh&","&bv&")"
click at loca,281-round(ratio*(av-minv))
type "A' ("&ah&","&av&")"
end if
choose browse tool
put 6 into cc
set cursor to 1
end coordinate
on mss
global ms
play "Boing"
put ms into the message box
wait 80
hide message box
set cursor to 1
end mss
-- part 15 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=11 top=311 right=333 bottom=95
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Formulas...
----- HyperTalk script -----
on mouseUp
go card 3
end mouseUp
-- part 17 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=338 top=144 right=306 bottom=419
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name:
-- part 19 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=418 top=144 right=304 bottom=498
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name:
-- part 20 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=277 top=4 right=16 bottom=289
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name:
-- part 21 (button)
-- low flags: 00
-- high flags: 2000
-- rect: left=415 top=25 right=46 bottom=437
-- title width / last selected line: 0
-- icon id / first selected line: 19678 / 19678
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: New Button
----- HyperTalk script -----
on mouseUp
if visible of card field 11 then hide card field 11
else show card field 11
end mouseUp
-- part 23 (field)
-- low flags: 81
-- high flags: 0004
-- rect: left=48 top=71 right=101 bottom=471
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name:
-- part 33 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=196 top=25 right=42 bottom=242
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Reset
----- HyperTalk script -----
on mouseUp
Answer "use Reset only to re-draw jumbled screen!" with "Cancel" or "OK"
if it is "cancel" then exit mouseup
if it is "OK" then
get the id of this card
if it is "card id 2661" then
play "boing"
put "You cannot re-draw the Sample Card. Use Reset from the 1st card" into message box
exit mouseup
end if
set lockscreen to true
set cursor to 4
go card id 2661
domenu copy card
go card 2
domenu paste card
click at loc of card field 13
select card field 13
domenu cut field
choose browse tool
go prev
set cantdelete of this card to false
domenu delete card
set lockscreen to false
set cursor to 1
end if
end mouseUp
-- part 34 (button)
-- low flags: 00
-- high flags: 2000
-- rect: left=447 top=304 right=342 bottom=491
-- title width / last selected line: 0
-- icon id / first selected line: 29114 / 29114
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: back to index
----- HyperTalk script -----
on mouseUp
go card 1
end mouseup
-- part 35 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=265 top=52 right=69 bottom=312
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Clear
----- HyperTalk script -----
on mouseUp
reset
end mouseUp
-- part 37 (field)
-- low flags: 81
-- high flags: 0004
-- rect: left=251 top=50 right=331 bottom=510
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name:
----- HyperTalk script -----
on mouseup
hide card field 11
end mouseup
-- part 38 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=264 top=145 right=304 bottom=337
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name:
-- part 29 (field)
-- low flags: 01
-- high flags: 0004
-- rect: left=80 top=146 right=197 bottom=372
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 18
-- style flags: 256
-- line height: 24
-- part name:
-- part contents for card part 23
----- text -----
For Angles, just enter the value (i.e. 45)
For Coordinates, enter the two coordinates separated by a "comma" (i.e. 981,762)
-- part contents for card part 29
----- text -----
This is a Sample Card used
for Re-Drawing the Screen
-- part contents for card part 37
----- text -----
To enter data, click on the angle
or line in the "Input" part of the screen, and enter your values. Then click on the "Calculate" button to see the results